using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace DataAccessLayer
{
    public class DAO_Role
    {
        public static bool Insert(Object tmp)
        {
            ROLE obj = (ROLE)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@QUESTION_TOPIC_MAP_ID", obj.QUESTION_TOPIC_MAP_ID));
            _list.Add(new SqlParameter("@ROLE_DESC", obj.ROLE_DESC));
            _list.Add(new SqlParameter("@ROLE_NAME", obj.ROLE_NAME));

            int n = clsDataAccessHelper.ExecNonQuery("sp_role_insert", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static bool Update(Object tmp)
        {
            ROLE obj = (ROLE)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@QUESTION_TOPIC_MAP_ID", obj.QUESTION_TOPIC_MAP_ID));
            _list.Add(new SqlParameter("@ROLE_DESC", obj.ROLE_DESC));
            _list.Add(new SqlParameter("@ROLE_NAME", obj.ROLE_NAME));

            int n = clsDataAccessHelper.ExecNonQuery("sp_role_update", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static bool Delete(Object tmp)
        {
            ROLE obj = (ROLE)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@QUESTION_TOPIC_MAP_ID", obj.QUESTION_TOPIC_MAP_ID));
            _list.Add(new SqlParameter("@ROLE_DESC", obj.ROLE_DESC));
            _list.Add(new SqlParameter("@ROLE_NAME", obj.ROLE_NAME));

            int n = clsDataAccessHelper.ExecNonQuery("sp_role_delete", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static List<ROLE> LoadAll()
        {
            List<ROLE> _list = new List<ROLE>();
            //call stored getlist here
            return _list;
        }
    }
}
